package msu.erdc.hci;

import msu.erdc.hci.customObjects.MyInfoObject;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MyInfo extends Fragment{
	
	EditText address;
	EditText city;
	EditText state;
	EditText zip;
	EditText phone;
	Button insuranceButton;
	Button licenseButton;	
	Button vehiclesButton;	
	MyInfoObject myInfo;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{
		View view =  inflater.inflate(R.layout.my_info, container, false);
		//do ui stuff here
		
		address = (EditText) view.findViewById(R.id.addressText);
		address.setText(myInfo.address);
		
		city = (EditText) view.findViewById(R.id.cityText);
		city.setText(myInfo.city);
		
		state = (EditText) view.findViewById(R.id.stateText);
		state.setText(myInfo.state);
		
		zip = (EditText) view.findViewById(R.id.zipText);
		zip.setText(myInfo.zip);
		
		phone = (EditText) view.findViewById(R.id.phoneText);
		phone.setText(myInfo.phone);
		
		licenseButton = (Button) view.findViewById(R.id.licenseButton);
		licenseButton.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				FragmentTransaction ft = getFragmentManager().beginTransaction();
				ft.replace(android.R.id.content, new LicenseInfo(), "licenseInfo");
				ft.addToBackStack(null);
				ft.commit();
			}
		});
		
		insuranceButton = (Button) view.findViewById(R.id.insuranceButton);
		insuranceButton.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				FragmentTransaction ft = getFragmentManager().beginTransaction();
				ft.replace(android.R.id.content, new InsuranceList(), "insuranceList");
				ft.addToBackStack(null);
				ft.commit();
			}
		});
		
		vehiclesButton = (Button) view.findViewById(R.id.vehicleButton);
        vehiclesButton.setOnClickListener(new OnClickListener(){

			public void onClick(View v) {
				FragmentTransaction ft = getFragmentManager().beginTransaction();
				ft.replace(android.R.id.content, new VehicleList(), "vehicleList");
				ft.addToBackStack(null);
				ft.commit();
			}});
        return view;
	}
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        myInfo = new MyInfoObject();
	}
}
